//---------------------------------------------------------------
//提供Object类的常用扩展函数
//---------------------------------------------------------------

Object.keys = function(obj) {
	var keys = []
	for ( var key in obj) {
		keys.push(key)
	}
	return keys
};

Object.values = function(obj) {
	var values = []
	for ( var key in obj) {
		values.push(obj[key])
	}
	return values
};

Object.entries = function(obj) {
	var entries = []
	for ( var key in obj) {
		entries.push({
			key : key,
			value : obj[key]
		})
	}
	return entries
}

/* ================ 深拷贝 ================ */
Object.deepClone = function(initalObj, finalObj) {
	var obj = finalObj || {};
    for (var i in initalObj) {
        var prop = initalObj[i];
        // 避免相互引用对象导致死循环，如initalObj.a = initalObj的情况
        if(prop === obj) {
            continue;
        }
        if (typeof prop === 'object') {
            obj[i] = (prop.constructor === Array) ? [] : Object.create(prop);
        } else {
            obj[i] = prop;
        }
    }
    return obj;
}